package elan.book.Render;


import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import elan.book.activity.R;

public class RenderBase extends Activity {
	private String tag = "RenderBase";
	private RelativeLayout lTitle;
	private LinearLayout lMenu;
	private LayoutInflater li;
	private ImageView titleImage;
	private TextView title_L, title_M, title_R;
	public FrameLayout Display = null;

	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
		// WindowManager.LayoutParams.FLAG_FULLSCREEN);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.baseview);
		Display = (FrameLayout) findViewById(R.id.myDisplay);
		titleImage = (ImageView) findViewById(R.id.Title_Image);
		title_L=(TextView)findViewById(R.id.Title_TextView01);
		title_M=(TextView)findViewById(R.id.Title_TextView02);
		title_R=(TextView)findViewById(R.id.Title_TextView03);
		init();
	}

	/**pls
	 * updataTitle()
	 * findAddViewById, do display.addview()
	 */
	public void init() {

	}

	public void showTitle() {
		lTitle.setVisibility(View.VISIBLE);
	}

	public void disableTitle() {
		lTitle.setVisibility(View.GONE);
	}

	public void showMenuBar() {
		lMenu.setVisibility(View.VISIBLE);
	}

	public void disableMenuBar() {
		lMenu.setVisibility(View.GONE);
	}

	public void updataTitle(Drawable drawable, String title_left,
			String title_middle, String title_right) {
		if (drawable != null) {
			titleImage.setVisibility(View.VISIBLE);
		} else {
			titleImage.setVisibility(View.GONE);
		}
		if (title_left != null) {
			title_L.setText(title_left);
		}
		if (title_middle != null) {
			title_M.setText(title_middle);
		}
		if (title_right != null) {
			title_R.setText(title_right);
		}
	}

	public View findAddViewById(int layoutid, int viewid) {
		if (li == null)
			li = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		return li.inflate(layoutid, null).findViewById(viewid);
	}
}
